<?php
$sch = new Swoole\Coroutine\Scheduler;
//创建一个协程
$sch->add(function () use ($sch) {
    //在协程里面创建一个协程TCP服务
    $server = new Swoole\Coroutine\Server("0.0.0.0", 3333);
    $server->handle(function (\Swoole\Coroutine\Server\Connection $con) use ($sch,$server) {
         while (true){
             $data = $con->recv();
             if($data === false || $data===""){
                 $con->close(1);
                 break;
             }
             //发送数据
             $con->send('hello');
             Co::sleep(1);
         }
    });
    $server->start();
});
$sch->start();